A Problem In Using Trigger with DXL

Hi Everyday

I encounter a problem using trigger mechanism in DXL, and couldn't make it through, so I'm writing here, looking for help
Firstly, I'll introduce my application background, I want to organize some Objects' progress in a formal module.
These Objects all have an attribute which type are "Enumeration", they works like drop-down list. Let's call it attribute A for further describe.
These Objects have another attribute, I created it myself, Let's call it attribute B.

Here is my question describe, to some object my current interest in, when attribute A changed it value, I want to realize it to fire a trigger, to pop-up a dialog box.

Currently, I am using dynamic trigger, and intended to write code in attribute B, please help me and tell me if this function can realize or not. It's more appreciate for you to provide some codes.
Thank you!
Aven_HIT - Fri Nov 27 01:13:50 EST 2009

Re: A Problem In Using Trigger with DXL
Mathias Mamsch - Sun Nov 29 13:21:08 EST 2009

Hi Aven_HIT,

before I answer your question - you may be wondering why no one replied to your post yet. When posting on a forum on the internet you should make sure that you at least try to correct errors in your post ('Hi everyday?!'). Your post is written so badly, that it is a little hard to understand what you are asking for. It would also be nice, if you signed your message with a name.

However, it is possible to have a trigger popup a dialog box, when an attribute is changed. You should be careful however, because popping up a dialog every time an attribute changes might give you thousands of dialog boxes, when a script fires the trigger for all objects on a module.

Example code attached.

Regards, Mathias



Put this code in a file called 'DialogTrigger.dxl' and put it in your DXL addins path, so it can install correctly.

 

 

string TName = "DialogTrigger"
 
Trigger T = current 
 
if (null T) {  // install code 
    Trigger installed
 
    // delete an old version of the trigger in the current module
    for installed in current Module do 
        if (name installed == TName) delete installed
 
    // reinstall the trigger
    installed = trigger ( TName, module->attribute->all, post, modify, 10, "#include <DialogTrigger.dxl>" )
 
    // check trigger installation    
    if (null installed) ack "Trigger could not be installed!"
 
} else {
    // Trigger code -> show a dialog
    DB c = centered "Triggered Dialog"
    label (c, "Please fill in the following attributes")
    show c
}

 

 

Re: A Problem In Using Trigger with DXL
llandale - Mon Nov 30 18:40:03 EST 2009

Your post is understandable enough.

It appears you want to present a dialog box when Attribute A changes, perhaps to set the value or Attribute B.

o You want an "Attribute Save" trigger.
o If you want to accept the value of A regardless then you want a "post" trigger,
if you want to possibly reject the value of A then you want a "pre" trigger.
o I'm sure you want a "stored/persistent" trigger, not a "dynamic" one, unless you have some mechanism in another module trigger to fire this one up.
o You could modify the trigger level expressly restricted for Attribute A, or the trigger code itself could query the attribute name and do nothing unless its A.

Looks like you want to define a trigger:

Module mod = current
if (null mod) error halt
if (!isEdit(mod)) error halt
 
string NameTrig = "PopulateB"
string DxlCode  = readFile("c:\\MyDxl\\PopulateB.dxl")
string ErrMess = checkDXL(DxlCode)
if (!null ErrMess) print ErrMess
if (confirm("Delete Trig"))  delete(NameTrig, attribute->"Attr A", post, save, 5)
if (null ErrMess   and 
    confirm("Deploy Trig")) trigger(NameTrig, attribute->"Attr A", post, save, 5, DxlCode).


PopulateB.dxl has the code for the dialog box. That may get a little tricky as the Object being saved might not be the 'current' object. That code should probably have this:

 

Trigger trg = current()
if (null trg) error, not running in a trigger
AttrDef ad = attrDef(trg)
etc.



Triggers are tricky, good luck.



 

 

 

  • Louie

 

 

Re: A Problem In Using Trigger with DXL
Aven_HIT - Tue Dec 01 21:32:53 EST 2009

Mathias Mamsch - Sun Nov 29 13:21:08 EST 2009

Hi Aven_HIT,

before I answer your question - you may be wondering why no one replied to your post yet. When posting on a forum on the internet you should make sure that you at least try to correct errors in your post ('Hi everyday?!'). Your post is written so badly, that it is a little hard to understand what you are asking for. It would also be nice, if you signed your message with a name.

However, it is possible to have a trigger popup a dialog box, when an attribute is changed. You should be careful however, because popping up a dialog every time an attribute changes might give you thousands of dialog boxes, when a script fires the trigger for all objects on a module.

Example code attached.

Regards, Mathias



Put this code in a file called 'DialogTrigger.dxl' and put it in your DXL addins path, so it can install correctly.

 

 

string TName = "DialogTrigger"
 
Trigger T = current 
 
if (null T) {  // install code 
    Trigger installed
 
    // delete an old version of the trigger in the current module
    for installed in current Module do 
        if (name installed == TName) delete installed
 
    // reinstall the trigger
    installed = trigger ( TName, module->attribute->all, post, modify, 10, "#include <DialogTrigger.dxl>" )
 
    // check trigger installation    
    if (null installed) ack "Trigger could not be installed!"
 
} else {
    // Trigger code -> show a dialog
    DB c = centered "Triggered Dialog"
    label (c, "Please fill in the following attributes")
    show c
}

 

 

First of all, It's my pleasure to take your advice, I tried to modify "everyday" to correct my mistake, unfortunately, I didn't find where to go, it's too slow for me to open this forum, and then, I give up, I am so sorry for everyone who read my post roughly, I am really sorry.
I will try your code and your advice at once, Thank you very much.
Regards, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Tue Dec 01 22:23:58 EST 2009

llandale - Mon Nov 30 18:40:03 EST 2009

Your post is understandable enough.

It appears you want to present a dialog box when Attribute A changes, perhaps to set the value or Attribute B.

o You want an "Attribute Save" trigger.
o If you want to accept the value of A regardless then you want a "post" trigger,
if you want to possibly reject the value of A then you want a "pre" trigger.
o I'm sure you want a "stored/persistent" trigger, not a "dynamic" one, unless you have some mechanism in another module trigger to fire this one up.
o You could modify the trigger level expressly restricted for Attribute A, or the trigger code itself could query the attribute name and do nothing unless its A.

Looks like you want to define a trigger:

Module mod = current
if (null mod) error halt
if (!isEdit(mod)) error halt
 
string NameTrig = "PopulateB"
string DxlCode  = readFile("c:\\MyDxl\\PopulateB.dxl")
string ErrMess = checkDXL(DxlCode)
if (!null ErrMess) print ErrMess
if (confirm("Delete Trig"))  delete(NameTrig, attribute->"Attr A", post, save, 5)
if (null ErrMess   and 
    confirm("Deploy Trig")) trigger(NameTrig, attribute->"Attr A", post, save, 5, DxlCode).


PopulateB.dxl has the code for the dialog box. That may get a little tricky as the Object being saved might not be the 'current' object. That code should probably have this:

 

Trigger trg = current()
if (null trg) error, not running in a trigger
AttrDef ad = attrDef(trg)
etc.



Triggers are tricky, good luck.



 

 

 

  • Louie

 

 

Thank you for your encourage and your help, It warms me up to go on my task, thank you.

When I use the "dynamic" trigger, when "attribute A" of one object changed, thousands of dialog window pop up, and couldn't close them all, this phenomenon abuse me, even after I set up conditions to pop up dialog window, the phenomenon still exists.

Hoping to slove this trouble after using "persistent" trigger.

Sincerely, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Wed Dec 02 03:56:57 EST 2009

Aven_HIT - Tue Dec 01 22:23:58 EST 2009
Thank you for your encourage and your help, It warms me up to go on my task, thank you.

When I use the "dynamic" trigger, when "attribute A" of one object changed, thousands of dialog window pop up, and couldn't close them all, this phenomenon abuse me, even after I set up conditions to pop up dialog window, the phenomenon still exists.

Hoping to slove this trouble after using "persistent" trigger.

Sincerely, Aven

My friend, after trying your code, I found out that the problem which thousand of dialog box pops up still exists even when I use persistent trigger.

Maybe I didn't describe my problem clearly, I want to pop up a dialog box when I changed one object's attribute. Eager for your help, thank you.

Sincerely Aven

Re: A Problem In Using Trigger with DXL
Mathias Mamsch - Wed Dec 02 16:21:54 EST 2009

Aven_HIT - Wed Dec 02 03:56:57 EST 2009
My friend, after trying your code, I found out that the problem which thousand of dialog box pops up still exists even when I use persistent trigger.

Maybe I didn't describe my problem clearly, I want to pop up a dialog box when I changed one object's attribute. Eager for your help, thank you.

Sincerely Aven

Hey Aven,

sorry for my "ranting" about your post! No hard feelings I hope? :-)

Ususally there should be exactly one dialog box for every attribute change, if you use a trigger like this. Even if you change the attribute in your trigger there should be only one dialog box, because while you are in the trigger other triggers are disabled (at least this is my experience I am not 100% sure of this).

There might be a a problem with your system, that the change of an attribute will cause the recalculation of a DXL attribute which will again fire the trigger lots of times. But this really depends on your setup and the specific code you are using.

If you post your source code we can maybe tell you where the problem is.

Best regards, Mathias

Re: A Problem In Using Trigger with DXL
llandale - Wed Dec 02 17:21:59 EST 2009

Aven_HIT - Wed Dec 02 03:56:57 EST 2009
My friend, after trying your code, I found out that the problem which thousand of dialog box pops up still exists even when I use persistent trigger.

Maybe I didn't describe my problem clearly, I want to pop up a dialog box when I changed one object's attribute. Eager for your help, thank you.

Sincerely Aven

You are going to have to post your code.

Also, run the following in your open module, maybe you got lots of triggers.

Trigger    trg
bool    DumpDxl = confirm("Print DXL of triggers?")
for trg in (current Module) do
{  if (kind(trg) == "builtin") continue
   print kind(trg) "\t" stringOf(type(trg)) "\t" stringOf(event(trg)) "\t"
   print stringOf(level(trg)) "\t" name(trg) "\n" 
   if (DumpDxl) print "\t" dxl(trg) "\n\n"
}

 

 

  • Louie

 

 

Re: A Problem In Using Trigger with DXL
Aven_HIT - Thu Dec 03 01:07:37 EST 2009

Mathias Mamsch - Wed Dec 02 16:21:54 EST 2009
Hey Aven,

sorry for my "ranting" about your post! No hard feelings I hope? :-)

Ususally there should be exactly one dialog box for every attribute change, if you use a trigger like this. Even if you change the attribute in your trigger there should be only one dialog box, because while you are in the trigger other triggers are disabled (at least this is my experience I am not 100% sure of this).

There might be a a problem with your system, that the change of an attribute will cause the recalculation of a DXL attribute which will again fire the trigger lots of times. But this really depends on your setup and the specific code you are using.

If you post your source code we can maybe tell you where the problem is.

Best regards, Mathias

Hey my dude Mathias

As I said, I'm really pleasure to take your advice, and will be more carefully to check my spelling.

Really appreciate for your reply, and I will post my code later, very much thanks to you for your attention to my problem.

Sincerely, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Thu Dec 03 01:16:29 EST 2009

llandale - Wed Dec 02 17:21:59 EST 2009

You are going to have to post your code.

Also, run the following in your open module, maybe you got lots of triggers.

Trigger    trg
bool    DumpDxl = confirm("Print DXL of triggers?")
for trg in (current Module) do
{  if (kind(trg) == "builtin") continue
   print kind(trg) "\t" stringOf(type(trg)) "\t" stringOf(event(trg)) "\t"
   print stringOf(level(trg)) "\t" name(trg) "\n" 
   if (DumpDxl) print "\t" dxl(trg) "\n\n"
}

 

 

  • Louie

 

 

Hey Louie

Thanks for your help so kindly. I'll try your code and post my code later.

Best wishes, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Mon Dec 07 10:23:51 EST 2009

Aven_HIT - Tue Dec 01 21:32:53 EST 2009
First of all, It's my pleasure to take your advice, I tried to modify "everyday" to correct my mistake, unfortunately, I didn't find where to go, it's too slow for me to open this forum, and then, I give up, I am so sorry for everyone who read my post roughly, I am really sorry.
I will try your code and your advice at once, Thank you very much.
Regards, Aven

Maybe I didn't describe my problem clearly, I will interpret it as follows, hope you won't feel boring.

In a formal module, saved many objects, these objects had two "Colum", named "Colum A" and "Colum B", the type of "Colum A" is "Enumeration".

My aim is to pop up a dialog box when I changed the value of "Colum A" of a object, through the dialog box, I'll get the keyboard input, and display it in the correspond place in "Colum B" of the object.

My operations are as follows:

Right click on the title "Colum B", select "DXL attribute", and then, input the code:
 

string TName = "ShowDialogBox"
Trigger T = current
if(null T)
{
    Trigger installed
        for installed in current Module do
                if(name installed == TName)
                        delete installed
 
        installed = trigger(TName, module->attribute->"SpecificAttribute", post, save, 5, "include<ShowDialogBox.dxl>")
 
        if(null installed)
                infoBox "Trigger could not be installed"
}

 


In the directory $Doors home \lib\dxl\add in\user, I saved "ShowDialogBox.dxl", the content of the file are as follows:

 

 

 

DB showBox = create "Get in the content"
DBE stringIn = field(showBox, "Plese input:", "No. of the days", 20)
 
void doGetInput(DB showBox){
s = get stringIn
display s
}
 
void doClearInput(DB showBox){
Set(stringIn, "")
}
 
apply(showBox, "Get", doGetInput)
apply(showBox, "Clear", doClearInput)
show showBox

 


Looking forward for your kindly reply, many thanks.

Sincerely, Aven

 

 

 

 

 

 

Re: A Problem In Using Trigger with DXL
Aven_HIT - Mon Dec 07 10:27:01 EST 2009

llandale - Wed Dec 02 17:21:59 EST 2009

You are going to have to post your code.

Also, run the following in your open module, maybe you got lots of triggers.

Trigger    trg
bool    DumpDxl = confirm("Print DXL of triggers?")
for trg in (current Module) do
{  if (kind(trg) == "builtin") continue
   print kind(trg) "\t" stringOf(type(trg)) "\t" stringOf(event(trg)) "\t"
   print stringOf(level(trg)) "\t" name(trg) "\n" 
   if (DumpDxl) print "\t" dxl(trg) "\n\n"
}

 

 

  • Louie

 

 

Hi llandale

I had post my code, it still can't work correctly, hoping for your help and many thanks to you~

Sincerely, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Mon Dec 07 10:30:15 EST 2009

Mathias Mamsch - Wed Dec 02 16:21:54 EST 2009
Hey Aven,

sorry for my "ranting" about your post! No hard feelings I hope? :-)

Ususally there should be exactly one dialog box for every attribute change, if you use a trigger like this. Even if you change the attribute in your trigger there should be only one dialog box, because while you are in the trigger other triggers are disabled (at least this is my experience I am not 100% sure of this).

There might be a a problem with your system, that the change of an attribute will cause the recalculation of a DXL attribute which will again fire the trigger lots of times. But this really depends on your setup and the specific code you are using.

If you post your source code we can maybe tell you where the problem is.

Best regards, Mathias

Hi Mathias

I post my code recently, the code still can't work correctly, eagerly for your help with great thanks.

Sincerely, Aven

Re: A Problem In Using Trigger with DXL
llandale - Mon Dec 07 18:27:16 EST 2009

Aven_HIT - Mon Dec 07 10:23:51 EST 2009

Maybe I didn't describe my problem clearly, I will interpret it as follows, hope you won't feel boring.

In a formal module, saved many objects, these objects had two "Colum", named "Colum A" and "Colum B", the type of "Colum A" is "Enumeration".

My aim is to pop up a dialog box when I changed the value of "Colum A" of a object, through the dialog box, I'll get the keyboard input, and display it in the correspond place in "Colum B" of the object.

My operations are as follows:

Right click on the title "Colum B", select "DXL attribute", and then, input the code:
 

string TName = "ShowDialogBox"
Trigger T = current
if(null T)
{
    Trigger installed
        for installed in current Module do
                if(name installed == TName)
                        delete installed
 
        installed = trigger(TName, module->attribute->"SpecificAttribute", post, save, 5, "include<ShowDialogBox.dxl>")
 
        if(null installed)
                infoBox "Trigger could not be installed"
}

 


In the directory $Doors home \lib\dxl\add in\user, I saved "ShowDialogBox.dxl", the content of the file are as follows:

 

 

 

DB showBox = create "Get in the content"
DBE stringIn = field(showBox, "Plese input:", "No. of the days", 20)
 
void doGetInput(DB showBox){
s = get stringIn
display s
}
 
void doClearInput(DB showBox){
Set(stringIn, "")
}
 
apply(showBox, "Get", doGetInput)
apply(showBox, "Clear", doClearInput)
show showBox

 


Looking forward for your kindly reply, many thanks.

Sincerely, Aven

 

 

 

 

 

 

Your code works, after declaring 'string s' and changing 'Set' to 'set'. the 'display' command appears to do nothing unless it running layout which it isn't.

Modified the code to declare the code if the trigger inline, and allows for not deploying the trigger (and thus deleting it).

You get 1000s of dialog boxes? Something then is setting attribute values in your code somewhere else.

You may want to have the trigger check if the module is open Visibly, and if the 'current' object is indeed the object being modified by the trigger. If either of these is false is very likely some DXL is altering the values, and you don't want to display a dialog box for each one.
 

  • Louie

 

string DXLCode = "
DB showBox = create \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
string s = get stringIn
display s
}
 
void doClearInput(DB showBox){
set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox
"  // end DXLCode
 
 
 
 
string TName = "ShowDialogBox"
Trigger T = current
if(null T)
{
    Trigger installed
        for installed in current Module do
                if(name installed == TName)
                        delete installed
      if (confirm("Deploy Trigger??"))
        { installed = trigger(TName, module->attribute->"aTest", post, save, 5, DXLCode)
 
          if(null installed)
                infoBox "Trigger could not be installed"
        }
}

 

Re: A Problem In Using Trigger with DXL
Mathias Mamsch - Tue Dec 08 02:48:20 EST 2009

Aven_HIT - Mon Dec 07 10:23:51 EST 2009

Maybe I didn't describe my problem clearly, I will interpret it as follows, hope you won't feel boring.

In a formal module, saved many objects, these objects had two "Colum", named "Colum A" and "Colum B", the type of "Colum A" is "Enumeration".

My aim is to pop up a dialog box when I changed the value of "Colum A" of a object, through the dialog box, I'll get the keyboard input, and display it in the correspond place in "Colum B" of the object.

My operations are as follows:

Right click on the title "Colum B", select "DXL attribute", and then, input the code:
 

string TName = "ShowDialogBox"
Trigger T = current
if(null T)
{
    Trigger installed
        for installed in current Module do
                if(name installed == TName)
                        delete installed
 
        installed = trigger(TName, module->attribute->"SpecificAttribute", post, save, 5, "include<ShowDialogBox.dxl>")
 
        if(null installed)
                infoBox "Trigger could not be installed"
}

 


In the directory $Doors home \lib\dxl\add in\user, I saved "ShowDialogBox.dxl", the content of the file are as follows:

 

 

 

DB showBox = create "Get in the content"
DBE stringIn = field(showBox, "Plese input:", "No. of the days", 20)
 
void doGetInput(DB showBox){
s = get stringIn
display s
}
 
void doClearInput(DB showBox){
Set(stringIn, "")
}
 
apply(showBox, "Get", doGetInput)
apply(showBox, "Clear", doClearInput)
show showBox

 


Looking forward for your kindly reply, many thanks.

Sincerely, Aven

 

 

 

 

 

 

Hey Aven,

don't put the trigger installation code in a DXL layout column! It seems you don't get the concept of trigger right yet.

A trigger is a piece of code that DOORS will run, when a specific event happens (like changing an attribute). You install it only once - the trigger installation code you have posted needs to be run only once on the module (over run DXL). Afterwards you can close the module, even close DOORS and when you open the module the trigger will still be there!

There seems to be one or two typos in your code. Firstly "include<ShowDialogBox.dxl>" should be "#include <ShowDialogBox.dxl>". And Set(stringIn, "") should be set(stringIn, "").

Otherwise your code looks ok. You have to watch out to have the right include path in your trigger. Try just running "#include <ShowDialogBox.dxl>" in the Run/DXL menu to see that there is no error. Usually the addins path is configured to be "lib/dxl/addins" so you would have to include the file using "#include <user/ShowDialogBox.dxl>".

Regards, Mathias

Re: A Problem In Using Trigger with DXL
doors36677 - Tue Dec 08 07:45:42 EST 2009

Mathias Mamsch - Tue Dec 08 02:48:20 EST 2009
Hey Aven,

don't put the trigger installation code in a DXL layout column! It seems you don't get the concept of trigger right yet.

A trigger is a piece of code that DOORS will run, when a specific event happens (like changing an attribute). You install it only once - the trigger installation code you have posted needs to be run only once on the module (over run DXL). Afterwards you can close the module, even close DOORS and when you open the module the trigger will still be there!

There seems to be one or two typos in your code. Firstly "include<ShowDialogBox.dxl>" should be "#include <ShowDialogBox.dxl>". And Set(stringIn, "") should be set(stringIn, "").

Otherwise your code looks ok. You have to watch out to have the right include path in your trigger. Try just running "#include <ShowDialogBox.dxl>" in the Run/DXL menu to see that there is no error. Usually the addins path is configured to be "lib/dxl/addins" so you would have to include the file using "#include <user/ShowDialogBox.dxl>".

Regards, Mathias

I suspect here is a case where this forum helping the poster is not advantageous to the poster unless the poster is working on a non-production DOORS installation.

An inexperience user using triggers can muck up the Production DOORS installation and affect all users.

I think the original poster should be encouraged to set a DOORS installation for test or get one-on-one help. In this case, a consultant would be good -- Kevin can do it.

Re: A Problem In Using Trigger with DXL
Aven_HIT - Thu Dec 10 07:43:16 EST 2009

llandale - Mon Dec 07 18:27:16 EST 2009

Your code works, after declaring 'string s' and changing 'Set' to 'set'. the 'display' command appears to do nothing unless it running layout which it isn't.

Modified the code to declare the code if the trigger inline, and allows for not deploying the trigger (and thus deleting it).

You get 1000s of dialog boxes? Something then is setting attribute values in your code somewhere else.

You may want to have the trigger check if the module is open Visibly, and if the 'current' object is indeed the object being modified by the trigger. If either of these is false is very likely some DXL is altering the values, and you don't want to display a dialog box for each one.
 

  • Louie

 

string DXLCode = "
DB showBox = create \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
string s = get stringIn
display s
}
 
void doClearInput(DB showBox){
set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox
"  // end DXLCode
 
 
 
 
string TName = "ShowDialogBox"
Trigger T = current
if(null T)
{
    Trigger installed
        for installed in current Module do
                if(name installed == TName)
                        delete installed
      if (confirm("Deploy Trigger??"))
        { installed = trigger(TName, module->attribute->"aTest", post, save, 5, DXLCode)
 
          if(null installed)
                infoBox "Trigger could not be installed"
        }
}

 

First of all, many many thanks for your revising on my code, today, I try it on my PC, they correctly works._

However, there is still a small obstacle on the way to achieve the goal, that is, when objectA how to dislay the "content" on "Colum B", the "content" is the keyboard input.

Of course, I mean when the value of "Colum A" of "objectA" changed, pop up a dialog box(already realized), received a value through keyboard, get the content of input and then display it on the "Colum B" of "objectA".

I tried to modify the DXLCode as follows:
 

string DXLCode = "
DB showBox = create \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
string s = get stringIn
 
//display s
 
//way A
Object o = current        //the attribute of ColumB is "string"      
o."ColumB" = s            //way A will generate a complie error : "badly formed token EOF" on this line
 
//way B
obj."ColumB" = s          //way B will generate the same error as way A
}
 
void doClearInput(DB showBox){
set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox
"  // end DXLCode

 


I didn't find the way to get through, please give me some hints or clues, many thanks!

Sincerely, Aven

 

Re: A Problem In Using Trigger with DXL
Mathias Mamsch - Thu Dec 10 13:21:07 EST 2009

Aven_HIT - Thu Dec 10 07:43:16 EST 2009

First of all, many many thanks for your revising on my code, today, I try it on my PC, they correctly works._

However, there is still a small obstacle on the way to achieve the goal, that is, when objectA how to dislay the "content" on "Colum B", the "content" is the keyboard input.

Of course, I mean when the value of "Colum A" of "objectA" changed, pop up a dialog box(already realized), received a value through keyboard, get the content of input and then display it on the "Colum B" of "objectA".

I tried to modify the DXLCode as follows:
 

string DXLCode = "
DB showBox = create \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
string s = get stringIn
 
//display s
 
//way A
Object o = current        //the attribute of ColumB is "string"      
o."ColumB" = s            //way A will generate a complie error : "badly formed token EOF" on this line
 
//way B
obj."ColumB" = s          //way B will generate the same error as way A
}
 
void doClearInput(DB showBox){
set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox
"  // end DXLCode

 


I didn't find the way to get through, please give me some hints or clues, many thanks!

Sincerely, Aven

 

Hey Aven,

why could you possibly get a compile error on a string? Are you probably missing some backslashes in front of the " here?

Try

o.\"ColumB\" = s

instead of

o."ColumnB" = s

 


By the way, it is a common mistake to use

 

Object o = current

in a trigger. This works 95% of the time but it will fail in certain situations where the current object is not equal to the object that has been changed. In a trigger to find the object that has changed always use:
 

Trigger T = current Trigger
Object o = object T
Module m = module T

to get the module or the object that are associated with the trigger event.

Regards, Mathias

Re: A Problem In Using Trigger with DXL
Aven_HIT - Thu Dec 10 21:45:24 EST 2009

Mathias Mamsch - Thu Dec 10 13:21:07 EST 2009

Hey Aven,

why could you possibly get a compile error on a string? Are you probably missing some backslashes in front of the " here?

Try

o.\"ColumB\" = s

instead of

o."ColumnB" = s

 


By the way, it is a common mistake to use

 

Object o = current

in a trigger. This works 95% of the time but it will fail in certain situations where the current object is not equal to the object that has been changed. In a trigger to find the object that has changed always use:
 

Trigger T = current Trigger
Object o = object T
Module m = module T

to get the module or the object that are associated with the trigger event.

Regards, Mathias

Hi Mathias,

I'm really fortunate to receive your help in such a short time and I'll try it immediately.

At the same time, I'm greatful for you to remind me to avoid the common mistake, thanks~~

Take your advice, and best regards!

Sincerely, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Thu Dec 10 21:57:45 EST 2009

doors36677 - Tue Dec 08 07:45:42 EST 2009
I suspect here is a case where this forum helping the poster is not advantageous to the poster unless the poster is working on a non-production DOORS installation.

An inexperience user using triggers can muck up the Production DOORS installation and affect all users.

I think the original poster should be encouraged to set a DOORS installation for test or get one-on-one help. In this case, a consultant would be good -- Kevin can do it.

Thanks for your advice, I'm glad to take it.

I'm really a beginner in Doors, although playing a role as database manager.

One-on-one help seems very amazing, I will consider it later~~

Best regards, Aven

Re: A Problem In Using Trigger with DXL
Aven_HIT - Fri Dec 11 01:15:09 EST 2009

Mathias Mamsch - Thu Dec 10 13:21:07 EST 2009

Hey Aven,

why could you possibly get a compile error on a string? Are you probably missing some backslashes in front of the " here?

Try

o.\"ColumB\" = s

instead of

o."ColumnB" = s

 


By the way, it is a common mistake to use

 

Object o = current

in a trigger. This works 95% of the time but it will fail in certain situations where the current object is not equal to the object that has been changed. In a trigger to find the object that has changed always use:
 

Trigger T = current Trigger
Object o = object T
Module m = module T

to get the module or the object that are associated with the trigger event.

Regards, Mathias

Hey Mathias,

At the beginning, thanks for reminding me to avoid the common mistake.

I had tried the way

o.\"ColumB\" = s


It could be complied without error, but the content which received from keyboard still couldn't display.

When I changed the value of "ColumA", dialog could be displayed correctly, when I click the button "Get", then a error occured.
The error message is "null object parameter was passed into argument position 1".

It seems the current object had not be caught, by the way, I used the following code

 

 

Trigger T = current Trigger
Object o = object T
o.\"ColumB\" = s



these code are in the callback function of button "Get".

It abuse me much, looking forward for your help, thanks.

Sincerely, Aven*



 

 

Re: A Problem In Using Trigger with DXL
Mathias Mamsch - Fri Dec 11 07:40:37 EST 2009

Aven_HIT - Fri Dec 11 01:15:09 EST 2009

Hey Mathias,

At the beginning, thanks for reminding me to avoid the common mistake.

I had tried the way

o.\"ColumB\" = s


It could be complied without error, but the content which received from keyboard still couldn't display.

When I changed the value of "ColumA", dialog could be displayed correctly, when I click the button "Get", then a error occured.
The error message is "null object parameter was passed into argument position 1".

It seems the current object had not be caught, by the way, I used the following code

 

 

Trigger T = current Trigger
Object o = object T
o.\"ColumB\" = s



these code are in the callback function of button "Get".

It abuse me much, looking forward for your help, thanks.

Sincerely, Aven*



 

 

The problem is probably that the 'Trigger T = current; Object o = object T' is in the callback function of the button. What is probably happening is, that when the trigger is executed your code will execute like this:

DB showbox = create (...) 
...
apply (...)
apply (...)
show showBox

 


The callbacks are not executed yet! After the show command, the trigger code ends and you cannot be sure, that the 'Trigger T = current; Object o = object T' will work correctly afterwards. So you should try and put the code like this:

 

 

 

string code = "
Trigger T = current
if (null T) { print \"No trigger, wtf?\"; halt }
Object o = object T
if (null o) { print \"No object to attribute change, wtf?\"; halt }
 
DB showBox = create  \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
   string s = get stringIn
   o.\"ColumnB\" = s
   // close the dialog box
   hide showBox
   // make DOORS show the changes to the object
   refresh module o
}
 
void doClearInput(DB showBox){
   set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox"
 
Trigger T2 
for T2 in current Module do { if (name T2 == "TestTrigger") delete T2 }
 
print null trigger ("TestTrigger", module->attribute->"Object Text", post, save, 10, code)



I tested this code on a test module, which had a text attribute called 'ColumnB'. I ran this code once (to install the trigger). Afterwards the trigger will show the dialog box everytime you change the "Object Text" (replace by ColumnA), until you deinstall it. On my testmodule it works fine.

Hope this help. Regards, Mathias



 

 

Re: A Problem In Using Trigger with DXL
Aven_HIT - Sat Dec 12 09:57:31 EST 2009

Mathias Mamsch - Fri Dec 11 07:40:37 EST 2009

The problem is probably that the 'Trigger T = current; Object o = object T' is in the callback function of the button. What is probably happening is, that when the trigger is executed your code will execute like this:

DB showbox = create (...) 
...
apply (...)
apply (...)
show showBox

 


The callbacks are not executed yet! After the show command, the trigger code ends and you cannot be sure, that the 'Trigger T = current; Object o = object T' will work correctly afterwards. So you should try and put the code like this:

 

 

 

string code = "
Trigger T = current
if (null T) { print \"No trigger, wtf?\"; halt }
Object o = object T
if (null o) { print \"No object to attribute change, wtf?\"; halt }
 
DB showBox = create  \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
   string s = get stringIn
   o.\"ColumnB\" = s
   // close the dialog box
   hide showBox
   // make DOORS show the changes to the object
   refresh module o
}
 
void doClearInput(DB showBox){
   set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox"
 
Trigger T2 
for T2 in current Module do { if (name T2 == "TestTrigger") delete T2 }
 
print null trigger ("TestTrigger", module->attribute->"Object Text", post, save, 10, code)



I tested this code on a test module, which had a text attribute called 'ColumnB'. I ran this code once (to install the trigger). Afterwards the trigger will show the dialog box everytime you change the "Object Text" (replace by ColumnA), until you deinstall it. On my testmodule it works fine.

Hope this help. Regards, Mathias



 

 

Hey, Mathias

Many thanks to you for your such a long time focus on my problem, I tried your code today, and it meet my application, the code works correctly, many many thanks.

Best regards, Aven

Re: A Problem In Using Trigger with DXL
muthurani - Thu Jan 07 09:40:18 EST 2010

Mathias Mamsch - Fri Dec 11 07:40:37 EST 2009

The problem is probably that the 'Trigger T = current; Object o = object T' is in the callback function of the button. What is probably happening is, that when the trigger is executed your code will execute like this:

DB showbox = create (...) 
...
apply (...)
apply (...)
show showBox

 


The callbacks are not executed yet! After the show command, the trigger code ends and you cannot be sure, that the 'Trigger T = current; Object o = object T' will work correctly afterwards. So you should try and put the code like this:

 

 

 

string code = "
Trigger T = current
if (null T) { print \"No trigger, wtf?\"; halt }
Object o = object T
if (null o) { print \"No object to attribute change, wtf?\"; halt }
 
DB showBox = create  \"Get in the content\"
DBE stringIn = field(showBox, \"Plese input:\", \"No. of the days\", 20)
 
void doGetInput(DB showBox){
   string s = get stringIn
   o.\"ColumnB\" = s
   // close the dialog box
   hide showBox
   // make DOORS show the changes to the object
   refresh module o
}
 
void doClearInput(DB showBox){
   set(stringIn, \"\")
}
 
apply(showBox, \"Get\", doGetInput)
apply(showBox, \"Clear\", doClearInput)
show showBox"
 
Trigger T2 
for T2 in current Module do { if (name T2 == "TestTrigger") delete T2 }
 
print null trigger ("TestTrigger", module->attribute->"Object Text", post, save, 10, code)



I tested this code on a test module, which had a text attribute called 'ColumnB'. I ran this code once (to install the trigger). Afterwards the trigger will show the dialog box everytime you change the "Object Text" (replace by ColumnA), until you deinstall it. On my testmodule it works fine.

Hope this help. Regards, Mathias



 

 

Hello Mathias,

My requirement is, if I add a text in "Object Text" column, it should automatically update the data into "ColumnB".

Please tell me how to assign a "Object Text" column text changes into "columnB" automatically instead of using "field box" and "Get" button.
Looking forward your reply.

Thanks in advance,
Muthurani M

Re: A Problem In Using Trigger with DXL
Aven_HIT - Mon Jan 11 10:11:23 EST 2010

muthurani - Thu Jan 07 09:40:18 EST 2010
Hello Mathias,

My requirement is, if I add a text in "Object Text" column, it should automatically update the data into "ColumnB".

Please tell me how to assign a "Object Text" column text changes into "columnB" automatically instead of using "field box" and "Get" button.
Looking forward your reply.

Thanks in advance,
Muthurani M

Hi, muthurani

There is a post recently which is talking about your problem, I remember. Please check it, I am sorry that I couldn't recall its subject clearly.

It was posted in recent ten days, maybe hopeful.

Best regards, Aven

Re: A Problem In Using Trigger with DXL
muthurani - Tue Jan 19 01:44:43 EST 2010

Aven_HIT - Mon Jan 11 10:11:23 EST 2010
Hi, muthurani

There is a post recently which is talking about your problem, I remember. Please check it, I am sorry that I couldn't recall its subject clearly.

It was posted in recent ten days, maybe hopeful.

Best regards, Aven

Hi Aven,

Thanks for your information.Sorry i couldnt able to find the correct post.

I have a question.
How to get the value of an object before starting the trigger and also i would like to use the value inside the trigger. Is there anypossible way of doing this.

Thanks in advance.

Best regards, Muthurani

Re: A Problem In Using Trigger with DXL
llandale - Tue Jan 19 17:59:33 EST 2010

muthurani - Tue Jan 19 01:44:43 EST 2010
Hi Aven,

Thanks for your information.Sorry i couldnt able to find the correct post.

I have a question.
How to get the value of an object before starting the trigger and also i would like to use the value inside the trigger. Is there anypossible way of doing this.

Thanks in advance.

Best regards, Muthurani

I'm not following the thread, but a pre-save-attr trigger can get the two values:

// code inside pre-save-attr trigger
Trigger trg = current
Object  obj = object(trg)
string  NameAttr = attrdef(trg)
 
string ValueNominated = value(trg)
string ValueCurrent   = obj.NameAttr
 
if (ValueNominated is unacceptable) //-
then set(TrigPreConFail)
else set(TrigPreConPass)
 
Check for nulls before using variables

 

 

  • Louie